package com.wuyou.mid;

/**
 * 3233. 统计不是特殊数字的数字数量
 *
 * @Date 2024/11/22 11:36
 * @Author 无忧
 */
public class NonSpecialCount {


    public static void main(String[] args) {
        int[] l = {10086764, 5, 4, 3693}, r = {96508040, 7, 16, 85366};
        for (int i = 3; i < l.length; i++) {
            System.out.println(sol_1(l[i], r[i]));
        }
    }

    public static int sol_1(int l, int r) {
        int ans = 0;

        int a=0;
        while (l <= r) {
            if (l == 1) {
                ans++;
                l++;
                continue;
            }


            double squareRoot = Math.sqrt(l);
            int squareRootInt = (int) squareRoot;
            int t = (squareRootInt + 1) * (squareRootInt + 1);
            if (squareRootInt * squareRootInt == l) {
                a++;
            }
            l++;
//                if (detect(l)) {
//                    ans++;
//                }
//                if (t <= r) {
//                    ans += t - l - 1;
//                }
//            } else {
//                if (t > r) {
//                    ans += r - l + 1;
//                    break;
//                } else {
//                    ans += (t - l);
//                }
//            }
//            l = t;

            // 1、能开平方，并且平方根不含除1以外的真因数，该数即是特殊数字
            // 2、不能开平方，l%2==0 && l/2!=2 该数就不是特殊数字

        }
        System.out.println(a);
        return ans;
    }

    public static boolean detect(int l) {
        int tempNum = 2, count = 1, midL = l / tempNum;
        while (tempNum <= midL && count <= 2) {
            if (l % tempNum == 0) {
                if (l / tempNum != tempNum) {
                    count += 2;
                } else {
                    count++;
                }
            }
            tempNum++;
            midL = l / tempNum;
        }
        if (count != 2) {
            return true;
        }
        return false;
    }
}
